<?php
	namespace Home\Controller;

	class OrdersController extends \Think\Controller{

		/*登录界面*/
		public function login(){
			if(IS_POST){
				$password = I('post.password');
				if($password == 'adminpassword'){
					session('user',1);
					$this->success('登录成功!',U('lists'));
				}else{
					$this->error('密码错误');
				}
			}else{
				$this->display();
			}
		}

		/*列表页面*/
		public function lists(){
			$user = session('user');
			if(!$user) $this->error('请先登录',U('login'));
			$data = M('photo_zm_print')->field('a.photo_id,a.electron_id,a.size,a.extract,a.remark,b.username,b.mobile,b.department,b.major,b.grade,b.class')->alias('a')->join('__PHOTO_ZM_DATA__ as b on a.photo_id = b.id')->select();
			foreach($data as $key => $val){
				if($val['electron_id'] == 0){
					$data[$key]['imgs'] = array(M('photo_zm_data')->where(array('id'=>$data['photo_id']))->getField('photo_url'));
				}else{
					$data[$key]['imgs'] = M('photo_zm_electron')->where(array('id'=>array('in',$val['electron_id'])))->getField('path',true);
				}
				
				$data[$key]['extract'] = $data[$key]['extract'] == 1 ? '自取': '上门';
			}
			$this->assign('data',$data);
			$this->display();
		}
	}